#include<bits/stdc++.h>
using namespace std;

int n;
int a,b,c;
struct Node{
    int a,b;
    string s;
    Node(){}
    Node(int a,int b,string s){
        this->a=a;
        this->b=b;
        this->s=s;
    }
    bool operator< (const Node& node) const{
        if(s.length()>node.s.length()) return true;
        if(s.length()<node.s.length()) return false;
        return s.compare(node.s)>0;
    }
};

struct Key{
    int a,b;
    Key(){}
    Key(int a,int b){
        this->a=a;
        this->b=b;
    }
    bool operator ==(const Key& key) const{
        return a==key.a&&b==key.b;
    }
};
// 自定义哈希函数
struct KeyHash {
    size_t operator()(const Key& key) const {
        // 计算各个字段的哈希值
        size_t h1 = hash<int>{}(key.a);
        size_t h2 = hash<int>{}(key.b);
        // 合并哈希值，通常使用 XOR 和位移操作
        return h1 ^ (h2 << 1);
    }
};

bool is_small(string s1,string s2){
    if(s1.length()<s2.length()) return true;
    if(s1.length()>s2.length()) return false;
    return s1.compare(s2)<0;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        string ans = "-";
        unordered_map<Key,string,KeyHash> dis;
        int aim;
        scanf("%d%d%d",&a,&b,&aim);
        priority_queue<Node> que;
        que.push(Node(0,0,""));
        dis[Key(a,b)]="";
        while (!que.empty())
        {
            Node node = que.top();
            que.pop();
            int ac=node.a;
            int bc=node.b;
            string sc=node.s;
            if(is_small(dis[Key(ac,bc)],sc)) continue;
            if(bc==aim){
                if(ans=="-"){
                    ans=sc;
                }
                else if(is_small(sc,ans)){
                    ans=sc;
                }
            }
            int an,bn;
            const int aa[]={0,a,ac,0,ac,ac+min(a-ac,bc),ac-min(ac,b-bc)};
            const int bb[]={0,bc,b,bc,0,bc-min(a-ac,bc),bc+min(ac,b-bc)};
            for(int j=1;j<=6;j++){
                an=aa[j];bn=bb[j];
                if(!dis.count(Key(an,bn))||is_small(sc+to_string(j),dis[Key(an,bn)]))
                {
                    que.push(Node(an,bn,sc+to_string(j)));
                    dis[Key(an,bn)] = sc+to_string(j);
                }
            }
        }
        cout<<ans.length()<<' ';
        for(auto c:ans){
            cout<<c<<' ';
        }
        cout<<endl;
    }
    return 0;
}
